import 'package:finance_app/src/entities/data_report_entity.dart';
import 'package:finance_app/src/entities/ocr_attachment_entity.dart';
import 'package:finance_app/src/entities/report_list_item_entity.dart';
import 'package:finance_app/src/entities/tax_submission_detail_entity.dart';

dataReportEntityFromJson(DataReportEntity data, Map<String, dynamic> json) {
	if (json['body'] != null) {
		data.body = (json['body'] as List).map((v) => ReportListItemEntity().fromJson(v)).toList();
	}
	if (json['meta'] != null) {
		data.meta = json['meta'];
	}
	if (json['start_date'] != null) {
		data.startDate = json['start_date'].toString();
	}
	if (json['attachments'] != null) {
		data.attachments = (json['attachments'] as List).map((v) => OcrAttachmentEntity().fromJson(v)).toList();
	}
	return data;
}

Map<String, dynamic> dataReportEntityToJson(DataReportEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['body'] =  entity.body?.map((v) => v.toJson())?.toList();
	data['meta'] = entity.meta;
	data['start_date'] = entity.startDate;
	data['attachments'] =  entity.attachments?.map((v) => v.toJson())?.toList();
	return data;
}

dataReportTotalFromJson(DataReportTotal data, Map<String, dynamic> json) {
	if (json['current'] != null) {
		data.current = json['current'] is String
				? int.tryParse(json['current'])
				: json['current'].toInt();
	}
	if (json['days_30'] != null) {
		data.days30 = json['days_30'] is String
				? int.tryParse(json['days_30'])
				: json['days_30'].toInt();
	}
	if (json['days_60'] != null) {
		data.days60 = json['days_60'] is String
				? int.tryParse(json['days_60'])
				: json['days_60'].toInt();
	}
	if (json['days_61'] != null) {
		data.days61 = json['days_61'] is String
				? int.tryParse(json['days_61'])
				: json['days_61'].toInt();
	}
	if (json['meta'] != null) {
		data.meta = json['meta'];
	}
	return data;
}

Map<String, dynamic> dataReportTotalToJson(DataReportTotal entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['current'] = entity.current;
	data['days_30'] = entity.days30;
	data['days_60'] = entity.days60;
	data['days_61'] = entity.days61;
	data['meta'] = entity.meta;
	return data;
}